时 间 记 忆
<<  < 2017 - >  >>
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
最 新 评 论
专 题 分 类
最 新 日 志
最 新 留 言
搜 索
用 户 登 录
友 情 连 接
博 客 信 息


 
VB6.0时间和时间戳互转
[ 2017-7-10 16:59:00 | By: xiao_xiong ]
 
'参数:strTime:要转换的时间;intTimeZone:该时间对应的时区   
'返回值:strTime相对于1970年1月1日午夜0点经过的秒数   
'示例:ToUnixTime("2008-5-23 10:51:0", +8),返回值为1211511060   
ToUnixTime(strTime, intTimeZone)  
    If IsEmpty(strTime) Or Not IsDate(strTime) Then strTime = Now  
    If IsEmpty(intTimeZone) Or Not IsNumeric(intTimeZone) Then intTimeZone = 0  
     ToUnixTime = DateAdd("h", -intTimeZone, strTime)  
     ToUnixTime = DateDiff("s", "1970-1-1 0:0:0", ToUnixTime)  
End  
         
'把UNIX时间戳转换为标准时间
'参数:intTime:要转换的UNIX时间戳;intTimeZone:该时间戳对应的时区
'返回值:intTime所代表的标准时间
'示例:FromUnixTime("1211511060", +8),返回值2008-5-23 10:51:0
FromUnixTime(intTime, intTimeZone)
    If IsEmpty(intTime) Or Not IsNumeric(intTime) Then
         FromUnixTime = Now()
    Exit
    End If
    If IsEmpty(intTime) Or Not IsNumeric(intTimeZone) Then intTimeZone = 0
    FromUnixTime = DateAdd("s", intTime, "1970-1-1 0:0:0")  
    FromUnixTime = DateAdd("h", intTimeZone, FromUnixTime)  
End  

 
 
发表评论:
 
天涯博客欢迎您!